package com.ltmonitor.web.controller.video;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ltmonitor.web.controller.PaginateAction;
import com.ltmonitor.web.util.JsonMessage;
import com.sun.tools.internal.xjc.generator.bean.ImplStructureStrategy.Result;

import net.sf.json.JSONObject;

@Controller
@RequestMapping("/vehicleRealTimeVideo")
public class VehicleRealTimeVideoAction extends PaginateAction {

	
	@RequestMapping("/editDefaultChannels.action")
	public String editDefaultChannels(Model model) {
		return "video/realTimeVideoEditChannels";
	}
	
	
	/**
	 * 请求批量编辑视频通道数据页面
	 * @param model
	 * @return
	 */
	@RequestMapping("/batchEditChannelsData.action")
	public String batchEditChannelsData(Model model) {
		return "video/batchEditChannelsData";
	}
	
	
	
	/**
	 * 获取车辆视频通道数据字符串
	 * @param jsonStr json格式参数
	 * @return
	 */
	@RequestMapping("/getChannelDataStr.action")
	public @ResponseBody JsonMessage getChannelDataStr(@RequestBody String jsonStr) {
		JsonMessage result = null;
		try {
			Map<String, Object> map = JSONObject.fromObject(jsonStr);
			// 查询条件
			String queryId = "video.selectVideoChannelsDataStr";
			List list = queryService.query(queryId, map);
			result = new JsonMessage(true, list);
			
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			result = new JsonMessage(false, e.getMessage());
		}
		
		return result;
	}
	
	
	/**
	 * 更新通道数据字符串
	 * @param jsonStr 参数信息字符串，json格式
	 * @return 更新结果
	 */
	@RequestMapping("/updateChannelDataStr.action")
	public @ResponseBody JsonMessage updateChannelDataStr(@RequestBody String jsonStr) {
		JsonMessage result = null;
		try {
			Map<String, Object> map = JSONObject.fromObject(jsonStr);
			// 查询条件
			String queryId = "video.updateVideoChannelsDataStr";
			List list = queryService.query(queryId, map);
			result = new JsonMessage(true, list);
			
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			result = new JsonMessage(false, e.getMessage());
		}
		
		return result;
	}
	
	
	/**
	 * 添加通道数据字符串
	 * @param jsonStr 参数信息字符串，json格式
	 * @return 更新结果
	 */
	@RequestMapping("/insertChannelDataStr.action")
	public @ResponseBody JsonMessage insertChannelDataStr(@RequestBody String jsonStr) {
		JsonMessage result = null;
		try {
			Map<String, Object> map = JSONObject.fromObject(jsonStr);
			// 查询条件
			String queryId = "video.insertVideoChannelsDataStr";
			List list = queryService.query(queryId, map);
			result = new JsonMessage(true, list);
			
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			result = new JsonMessage(false, e.getMessage());
		}
		
		return result;
	}
	
	
	
	
	
	/**
	 * 获取数据库中所有保存的视频通道信息
	 * @return
	 */
	@RequestMapping("/getAllChannelsDataStr.action")
	public @ResponseBody JsonMessage getAllChannelsDataStr(@RequestBody String jsonStr) {
		JsonMessage result = null;
		try {
			Map<String, Object> map = JSONObject.fromObject(jsonStr);
			String queryId = "video.selectAllVideoChannelsDataStr";
			List list = queryService.query(queryId, map);
			result = new JsonMessage(true, list);
			
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			result = new JsonMessage(false, e.getMessage());
		}
		return result;
	}
	
	/**
	 * 获取数据库中所有终端的类型信息
	 * @return
	 */
	@RequestMapping("/getAllTerminalData.action")
	public @ResponseBody JsonMessage getAllTerminalData(@RequestBody String jsonStr) {
		JsonMessage result = null;
		try {
			Map<String, Object> map = JSONObject.fromObject(jsonStr);
			String queryId = "video.selectAllTerminalData";
			List list = queryService.query(queryId, map);
			result = new JsonMessage(true, list);
			
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			result = new JsonMessage(false, e.getMessage());
		}
		return result;
	}
	
	
	/**
	 * 获取数据库中所有转发车辆信息
	 * @param jsonStr
	 * @return
	 */
	@RequestMapping("/getAllTransmitData.action")
	public @ResponseBody JsonMessage getAllTransmitData(@RequestBody String jsonStr) {
		JsonMessage result = null;
		try {
			Map<String, Object> map = JSONObject.fromObject(jsonStr);
			String queryId = "video.selectAllTransmitDatas";
			List list = queryService.query(queryId, map);
			result = new JsonMessage(true, list);
			
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			result = new JsonMessage(false, e.getMessage());
		}
		return result;
	}
	
	/**
	 * 添加转发车辆字符串
	 * @param jsonStr 参数信息字符串，json格式
	 * @return 更新结果
	 */
	@RequestMapping("/insertTransmitData.action")
	public @ResponseBody JsonMessage insertTransmitData(@RequestBody String jsonStr) {
		JsonMessage result = null;
		try {
			Map<String, Object> map = JSONObject.fromObject(jsonStr);
			// 查询条件
			String queryId = "video.insertTransmitData";
			List list = queryService.query(queryId, map);
			result = new JsonMessage(true, list);
			
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			result = new JsonMessage(false, e.getMessage());
		}
		
		return result;
	}
	
	
	/**
	 * 更新转发车辆字符串
	 * @param jsonStr 参数信息字符串，json格式
	 * @return 更新结果
	 */
	@RequestMapping("/updateTransmitData.action")
	public @ResponseBody JsonMessage updateTransmitData(@RequestBody String jsonStr) {
		JsonMessage result = null;
		try {
			Map<String, Object> map = JSONObject.fromObject(jsonStr);
			// 查询条件
			String queryId = "video.updateTransmitData";
			List list = queryService.query(queryId, map);
			result = new JsonMessage(true, list);
			
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			result = new JsonMessage(false, e.getMessage());
		}
		
		return result;
	}
	
}
